require([
    'jquery',
    'module/util',
    'global',
    'jquery.chosen',
	'requirejs/domready!'],
function($, util, g) {
	
	$("#category-number-select").chosen({
		width: "100%",
		no_results_text: "没有发现记录匹配"
	}); 
	$('#edit-vmf-modal').on('show.bs.modal', function(){
		var obj = $(this).data('obj');
		if(!obj){
			$(this).find('.modal-header .action').text('添加');
		}else{
			$(this).find('.modal-header .action').text('编辑');
		}
		obj = obj || {};
		$(this).find('form input, form select').each(function(){
			if($(this).attr('name')){
				$(this).val(obj[[$(this).attr('name')]]);
			}
		});
		$(this).find('form select').trigger("chosen:updated");
	}).on('click', '.btn-primary', function(){
		var d = {};
		$('#edit-vmf-modal').find('form input, form select').each(function(){
			if($(this).attr('name')){
				d[$(this).attr('name')] = $(this).val();
			}
		});
		if(d.id){
			d.changed = true;
			d.id = parseInt(d.id+'');
		}
		$('#edit-vmf-modal').modal('hide');
		$(window).trigger('ok.xt.modal', ['#edit-vmf-modal',d]);
	});
});